// nodejs http服务器后端使用pug模板

const express = require('express')
const pug = require('pug')
const path = require('path')
const app = express()

// 引入pug模板
app.set('views', path.join(__dirname, 'view'));
app.set('view engine', 'pug');

console.log(process.env.NODE_ENV)


app.get('/',(req,res)=>{
	res.send('hello world')
})
app.get('/index', function (req, res) {
  res.locals.message = 123
  res.render('index', {error:'error'})
})

app.listen(8080,function(){
	console.log('http://localhost:8080  serving')
})

// setImmediate(()=>{process.exit(0)},0)

process.on('beforeExit', (code) => {
  console.log('Process beforeExit event with code: ', code);
});

process.on('exit', (code) => {
  console.log('Process exit event with code: ', code);
});

